using System.Security.Cryptography;
using System.Text;

namespace octalforty.Waffle.ComponentModel.Security.Impl
{
    /// <summary>
    /// Standard implementation of the <see cref="ISecurityService"/>.
    /// </summary>
    public class SecurityService : ISecurityService
    {
        #region Private Member Variables
        private SHA1 sha1;
        #endregion

        /// <summary>
        /// Initializes a new instance of <see cref="SecurityService"/> class.
        /// </summary>
        public SecurityService()
        {
            sha1 = SHA1CryptoServiceProvider.Create();
        }

        #region ISecurityService Members
        /// <summary>
        /// Computes the hash value for the <paramref name="password"/>.
        /// </summary>
        /// <param name="password"></param>
        /// <returns></returns>
        public byte[] GetPasswordHash(string password)
        {
            return sha1.ComputeHash(Encoding.UTF8.GetBytes(password));
        }
        #endregion
    }
}
